package flight

import (
	"gitee.com/skew/mu_grpc/go/base"
	"gitee.com/skew/mu_grpc/go/mqttprotocol/airport"
)

type Camera struct {
	PayloadIndex         string              //相机编号
	VideoType            string              //镜头类型 1---zoom 2--ir 3---wide
	ZoomFactor           float32             //zoom变焦倍数
	IrZoomFactor         float32             //ir变焦倍数  `json:"ir_zoom_factor"`
	IrMeteringMode       int                 `json:"ir_metering_mode"`
	IrMeteringPoint      IrMeteringPoint     `json:"ir_metering_point"`
	IRMeteringAreaObject IrMeteringArea      `json:"ir_metering_area"`
	LiveviewWorldRegion  LiveviewWorldRegion `json:"liveview_world_region"`
	CameraMode           int                 `json:"CameraMode"` //{"0":"拍照","1":"录像","2":"智能低光","3":"全景拍照"}
}
type Gimbal struct {
	Pitch                   float64
	Roll                    float64
	Yaw                     float64
	MeasureTargetLongitude  float64 `json:"measure_target_longitude"`   //激光测距目标经度{"max":"180","min":"-180","unit_name":"度 / °"}
	MeasureTargetLatitude   float64 `json:"measure_target_latitude"`    //激光测距目标纬度{"max":"90","min":"-90","unit_name":"度 / °"}
	MeasureTargetAltitude   float64 `json:"measure_target_altitude"`    //激光测距目标海拔{"unit_name":"米 / m"}
	MeasureTargetDistance   float64 `json:"measure_target_distance"`    //激光测距距离{"unit_name":"米 / m"}
	MeasureTargetErrorState float64 `json:"measure_target_error_state"` //激光测距状态{"0":"NORMAL","1":"TOO_CLOSE","2":"TOO_FAR","3":"NO_SIGNAL"}
}

//	MQTTFlightData
//	@Description: 发送给前端的无人机数据
//
// @Time 2024-06-04 14:27:37
type MQTTFlightData struct {
	BaseFlightData
	CameraObject Camera `json:"Camera"`
	GimbalObject Gimbal `json:"Gimbal"`

	WindSpeed    float64            `json:"WindSpeed"` //风速 {"min":"-1.4E-45","max":"3.4028235E38","unit":"m/s","unitName":"米每秒","step":"0.1"}
	NetworkState NetworkStateData   `json:"NetworkState"`
	IsFixed      int                `json:"IsFixed"`   //是否收敛	{"0":"非开始","1":"收敛中","2":"收敛成功","3":"收敛失败"}
	RtkNumber    int                `json:"RtkNumber"` //RTK 搜星数量
	Battery      BatteryItem        `json:"battery"`
	Payloads     []airport.Payloads `json:"payloads"` //1 喊话器 speaker，2 探照灯 light，3抛投器 dropper，4激光雷达 lidar

}

type NetworkStateData struct {
	Networttype int     `json:"type"`    //网络类型	{"1":"4G","2":"以太网"}
	Quality     int     `json:"quality"` //网络质量	{"0":"差","1":"中","2":"好"}
	Rate        float64 `json:"rate"`    //网络速率
}
type BatteryItem struct {
	CapacityPercent  int             `json:"capacity_percent"`   //总剩余电量 {"min":0,"max":100}
	RemainFlightTime int             `json:"remain_flight_time"` //剩余飞行时间 {"unit":"秒"}
	ReturnHomePower  int             `json:"return_home_power"`  //返航所需电量百分比 {"min":0,"max":100}
	LandingPower     int             `json:"landing_power"`      //强制降落电量百分比{"min":0,"max":100}
	Batteries        []BatteriesItem `json:"batteries"`          //电池详细信息
}
type BatteriesItem struct {
	CapacityPercent        int     `json:"capacity_percent"`          //电池剩余电量 //{"min":0,"max":100}
	Index                  int     `json:"index"`                     //电池序号;{"min":"0"}
	Sn                     string  `json:"sn"`                        //电池编号
	Type                   int     `json:"type"`                      //电池类型
	SubType                int     `json:"sub_type"`                  //电池子类型
	FirmwareVersion        string  `json:"firmware_version"`          //电池固件版本
	LoopTimes              int     `json:"loop_times"`                //电池循环次数
	Voltage                int     `json:"voltage"`                   //电压{"unit":"毫伏"}
	Temperature            float32 `json:"temperature"`               //温度{"unit":"摄氏度"}
	HighVoltageStorageDays int     `json:"high_voltage_storage_days"` //高电压存储天数{"unit":"天"}
}

//	DBFlightData
//	@Description: 数据库存储的无人机数据
//
// @Time 2025-04-19 11:09:19
type DBFlightData struct {
	BaseFlightData
	GimbalItem base.JSON `gorm:"column:gimbal_item" ` //云台信息
	FlightCode string    `gorm:"-" json:"flight_code"`
}

//	FlightDataPara
//	@Description: 接收自有无人机通过http传入的实时数据
//
// @Time 2025-04-19 11:32:40
type FlightDataPara struct {
	BaseFlightData
	GimbalItem GimbalItemObject   `json:"Gimbal"`   //云台信息
	Payloads   []airport.Payloads `json:"payloads"` ////1 喊话器，2 探照灯，3抛投器，4激光雷达 等负载
}
type PsdkWidget struct {
	PsdkIndex      int    `json:"psdk_index"`       // 设备索引
	PsdkLibVersion string `json:"psdk_lib_version"` // 库版本号
	PsdkName       string `json:"psdk_name"`        // 设备名称
	PsdkSn         string `json:"psdk_sn"`          // 设备序列号
	PsdkVersion    string `json:"psdk_version"`     // 设备版本号
	//Speaker        Speaker `json:"speaker"`          // 音频播放参数
	//Values         []Value `json:"values"`           // 传感器数值列表
}
